package com.yqw.spring1219.dp.a_filter;

import java.util.ArrayList;
import java.util.List;

/**
 * 责任链整体也是看作是一个Filter
 * @author abc
 *
 */
public class FilterChain implements Filter{
	private List<Filter> filters = new ArrayList<>();
	
	public FilterChain addFilter(Filter filter) {
		this.filters.add(filter);
		return this;
	}

	@Override
	public void doFilter(Request request, Response response) {
		for (Filter filter : filters) {
			filter.doFilter(request, response);
		}
		response.setResponse(request.getRequestStr());
		
	}
}
